
package com.jf.cloud.biz.linstener;

import com.jf.cloud.api.order.feign.OrderFeignClient;
import com.jf.cloud.biz.service.SendMessageService;
import com.jf.cloud.common.order.vo.SendNotifyBO;
import com.jf.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zz
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.SEND_GROUP_NOTIFY_TO_USER_TOPIC,consumerGroup = RocketMqConstant.SEND_GROUP_NOTIFY_TO_USER_TOPIC)
public class OrderGroupBizConsumer implements RocketMQListener<SendNotifyBO> {

    @Autowired
    private SendMessageService sendMessageService;
    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 开团成团相关通知（开团成功、拼团成功、拼团失败）
     */
    @Override
    public void onMessage(SendNotifyBO sendNotifyBO) {
        // 获取订单相关信息
        SendNotifyBO sendNotifyDb = orderFeignClient.getOrderDetailInfo(sendNotifyBO.getBizId()).getData();
        sendNotifyDb.setSendType(sendNotifyBO.getSendType());
        sendMessageService.sendOrderNotifyMsgToShop(sendNotifyDb);
    }
}
